@ma If the data is is fixed, you can preallocate the bytes string like:
data = b"\x01\x02\x03\x05"
# and later
spi.write(data)
But that only saves some time before the writing starts. The writing speed itself will not be affected and is most likely slower than 40 MHz. The baud rate you specify is just an upper limit.